﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FlowerShop.Models
{
    public class Mapper
    {
        public static Category cateFromModels(CategoriesModels cateModel)
        {
            Category cate = new Category();
            cate.CateID = cateModel.CateId;
            cate.CateaName = cateModel.CateName;
            cate.Desription = cateModel.Description;
            return cate;
        }


        public static CategoriesModels cateToModels(Category cate)
        {
            CategoriesModels cateModel = new CategoriesModels();
            cateModel.CateId = cate.CateID;
            cateModel.CateName = cate.CateaName;
            cateModel.Description = cate.Desription;
            return cateModel;
        }

        // Mapper Customer 
        public static Customer customerFromModel(CustomerModels custModel)
        {
            Customer cust = new Customer 
            { CustomerID=custModel.CustomerID,
                LoginName=custModel.LoginName,
                CustomerPassWord=custModel.CustomerPassword,
                FullName=custModel.FullName,
                Email=custModel.Email,
                Address=custModel.Address,
                City=custModel.City,
                Phone=custModel.Phone,
                Mobile=custModel.Mobile,
                Status=custModel.Status
            };
            return cust;
        }

        public static Customer customerToModel(Customer cust)
        {
            Customer custModel = new Customer
            {
                CustomerID = cust.CustomerID,
                LoginName = cust.LoginName,
                CustomerPassWord = cust.CustomerPassWord,
                FullName = cust.FullName,
                Email = cust.Email,
                Address = cust.Address,
                City = cust.City,
                Phone = cust.Phone,
                Mobile = cust.Mobile,
                Status = cust.Status
            };
            return cust;
        }

        public static Order orderFromModel(OrderModels orderModel)
        {
            Order od = new Order();
            od.OrderID = orderModel.OrderID;
            od.CustomerID = orderModel.CustomerID;
            od.OrderDate = orderModel.OrderDate;
            od.RequireDate = orderModel.RequireDate;
            od.ShipAddress = orderModel.ShipAddress;
            od.ShipName = orderModel.ShipName;
            od.Phone = orderModel.Phone;
            od.Mobile = orderModel.Mobile;
            od.Messages = orderModel.Messages;
            od.Desription = orderModel.Desription;
            od.PaidTypeID = orderModel.PaidTypeID;
            od.PriceSum = orderModel.PriceSum;
            od.Status = orderModel.Status;
            return od;
        }
        public static OrderModels orderToModel(Order order)
        {
            OrderModels odrmodel = new OrderModels();
            odrmodel.OrderID = order.OrderID;
            odrmodel.CustomerID = order.CustomerID;
            odrmodel.OrderDate = (DateTime) order.OrderDate;
            odrmodel.RequireDate = order.RequireDate;
            odrmodel.ShipAddress = order.ShipAddress;
            odrmodel.ShipName = order.ShipName;
            odrmodel.Phone = order.Phone;
            odrmodel.Mobile = order.Mobile;
            odrmodel.Messages = order.Messages;
            odrmodel.Desription = order.Desription;
            odrmodel.PaidTypeID =(int) order.PaidTypeID;
            odrmodel.PriceSum = (int)order.PriceSum;
            odrmodel.Status = (int)order.Status;
            return odrmodel;
        }

        public static PaidType paidtypeFromModels(PaidTypeModels PaidModel)
        {
            PaidType Paid = new PaidType();
            Paid.PaidTypeID = PaidModel.PaidTypeID;
            Paid.PaidTypeName = PaidModel.PaidTypeName;
            return Paid;
        }


        public static PaidTypeModels paidtypeToModels(PaidType Paid)
        {
            PaidTypeModels PaidModel = new PaidTypeModels();
            PaidModel.PaidTypeID = Paid.PaidTypeID;
            PaidModel.PaidTypeName = Paid.PaidTypeName;
            return PaidModel;
        }

        //procduct
        public static Product productFromModel(ProductsModels productModel)
        {
            Product pro = new Product();
            pro.ProductID = productModel.ProductID;
            pro.ProductName = productModel.ProductName;
            pro.CateID = (int)productModel.CateID;
            pro.UnitPrice = productModel.UnitPrice;
            pro.Desription = productModel.Description;
            pro.PictureS = productModel.PictureS;
            pro.PictureM = productModel.PictureM;
            pro.Status = productModel.Status;
            return pro;
        }
        public static ProductsModels productToModel(Product product)
        {
            ProductsModels promodel = new ProductsModels();
            promodel.ProductID = product.ProductID;
            promodel.ProductName = product.ProductName;
            promodel.CateID = (int)product.CateID;
            promodel.UnitPrice = product.UnitPrice;
            promodel.Description = product.Desription;
            promodel.PictureS = product.PictureS;
            promodel.PictureM = product.PictureM;
            promodel.Status = product.Status;
            return promodel;
        }
        

        //Bảng History
        public static History historyFromModels(HistoryModels historyModels)
        {
            History history = new History();
            history.HistoryID = historyModels.historyID;
            history.OrderID = historyModels.historyID;
            return history;
        }

        public static HistoryModels historyToModels(History history)
        {
            HistoryModels historymodel = new HistoryModels();
            historymodel.historyID = history.HistoryID;
            historymodel.orderID = int.Parse(history.OrderID.ToString());
            return historymodel;
        }


    }
}